<%@ page import="org.ikastola.PaymentCheck" %>

<script>
function clearCheckForm() {
	$("#number").val("");
	$("#bank").val("");
	$("#amount").val("");
	$("#mode").val("1");
	$("#owner").val("");
	$("#account").val("");
	return true
}

function validateCheckForm() {
	var valid = true;
	var info = "&nbsp;Dato ingresado inv&aacute;lido!";
	if (!$("#number")[0].validity.valid) {
		valid = false;
		$("#numberUpd").html(info);
	} else {
		$("#numberUpd").html("");
	}
	if (!$("#bank")[0].validity.valid) {
		valid = false;
		$("#bankUpd").html(info);
	} else {
		$("#bankUpd").html("");
	}
	if (!$("#amount")[0].validity.valid) {
		valid = false;
		$("#amountUpd").html(info);
	} else {
		$("#amountUpd").html("");
	}
	if (!$("#account")[0].validity.valid) {
		valid = false;
		$("#accountUpd").html(info);
	} else {
		$("#accountUpd").html("");
	}
	if (!$("#owner")[0].validity.valid) {
		valid = false;
		$("#ownerUpd").html(info);
	} else {
		$("#ownerUpd").html("");
	}
	return valid;
}
</script>
<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'number', 'error')} required">
	<label for="number" style="width: 16%;">
		<g:message code="paymentCheck.number.label" default="Number" />
		<span class="required-indicator">*</span>
	</label>
	<input name="number" id="number" type="number" value="${paymentCheckInstance?.number}" required />&nbsp;<div id="numberUpd" style="color:#ff5555;display:inline;"></div>
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'bank', 'error')} required">
	<label for="bank" style="width: 16%;">
		<g:message code="paymentCheck.bank.label" default="Bank" />
		<span class="required-indicator">*</span>
	</label>
	<input name="bank" id="bank" type="text" value="${paymentCheckInstance?.bank}" required />&nbsp;<div id="bankUpd" style="color:#ff5555;display:inline;"></div>
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'amount', 'error')} required">
	<label for="amount" style="width: 16%;">
		<g:message code="paymentCheck.amount.label" default="Amount" />
		<span class="required-indicator">*</span>
	</label>
	<input name="amount" id="amount" type="number" step="0.05" value="${paymentCheckInstance?.amount}" required />&nbsp;<div id="amountUpd" style="color:#ff5555;display:inline;"></div>
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'account', 'error')} required">
	<label for="account" style="width: 16%;">
		<g:message code="paymentCheck.account.label" default="Account" />
		<span class="required-indicator">*</span>
	</label>
	<input type="text" name="account" id="account" value="${paymentCheckInstance?.account}" required />&nbsp;<div id="accountUpd" style="color:#ff5555;display:inline;"></div>
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'owner', 'error')} required">
	<label for="owner" style="width: 16%;">
		<g:message code="paymentCheck.owner.label" default="Owner" />
		<span class="required-indicator">*</span>
	</label>
	<input type="text" name="owner" id="owner" value="${paymentCheckInstance?.owner}" required />&nbsp;<div id="ownerUpd" style="color:#ff5555;display:inline;"></div>
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'checkdate', 'error')} required">
	<label for="checkdate" style="width: 16%;">
		<g:message code="paymentCheck.checkdate.label" default="Checkdate" />
		<span class="required-indicator">*</span>
	</label>
	<g:datePicker name="checkdate" precision="day"  value="${paymentCheckInstance?.checkdate}"  relativeYears="[-3..3]"/>
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'paydate', 'error')} required">
	<label for="paydate" style="width: 16%;">
		<g:message code="paymentCheck.paydate.label" default="Paydate" />
		<span class="required-indicator">*</span>
	</label>
	<g:datePicker name="paydate" precision="day"  value="${paymentCheckInstance?.paydate}" relativeYears="[-3..3]" />
</div>

<div class="fieldcontain ${hasErrors(bean: paymentCheckInstance, field: 'mode', 'error')} required">
	<label for="mode" style="width: 16%;">
		<g:message code="paymentCheck.mode.label" default="Mode" />
		<span class="required-indicator">*</span>
	</label>
	<select id="mode" name="mode">
		<option value="${ikastola.Constants.IMMEDIATE_CHECK}">Inmediato</option>
		<option value="2">A 30 d&iacute;as</option>
		<option value="3">A 60 d&iacute;as</option>
		<option value="4">A 90 d&iacute;as</option>
	</select>
</div>


